<script setup>
import { useRouter } from 'vue-router'

const router = useRouter()
const emit = defineEmits(['logout'])

const handleCommand = (command) => {
  if (command === 'logout') {
    emit('logout')
  }
}
</script>

<template>
  <el-header height="64px" class="header">
    <div class="header-left">
      <h2>AI数字人知识问答系统</h2>
    </div>
    <div class="header-right">
      <el-dropdown @command="handleCommand">
        <span class="user-info">
          <el-avatar :size="32" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
          <span class="username">管理员</span>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item command="logout">
              退出登录
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </el-header>
</template>

<style scoped>
.header {
  background-color: #fff;
  border-bottom: 1px solid #e6e6e6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 64px;
}

.header-left h2 {
  margin: 0;
  font-size: 20px;
  color: #333;
}

.header-right .user-info {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.header-right .username {
  margin-left: 8px;
  font-size: 14px;
  color: #333;
}

.el-dropdown-menu__item .el-icon {
  margin-right: 8px;
}
</style>